﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;
using System;

namespace AMatysiakTest.Methods
{
    [TestClass]
    public class SubstringLastToTest
    {
        private string text = "Zwolnijmy... Ale co? Ten galop";

        [TestMethod]
        public void emptyText()
        {
            string substr = text.SubstringLastTo("");
            Assert.AreEqual("Zwolnijmy... Ale co? Ten galop", substr);
        }

        [TestMethod]
        public void toSecondWord()
        {
            string substr = text.SubstringLastTo("...");
            Assert.AreEqual("Zwolnijmy...", substr);
        }

        [TestMethod]
        public void toLastSpace()
        {
            string substr = text.SubstringLastTo(" ");
            Assert.AreEqual("Zwolnijmy... Ale co? Ten ", substr);
        }

        [TestMethod]
        public void toOneChar()
        {
            string substr = text.SubstringLastTo("?");
            Assert.AreEqual("Zwolnijmy... Ale co?", substr);
        }

        [TestMethod]
        public void oneLetter()
        {
            string substr = text.SubstringLastTo("g");
            Assert.AreEqual("Zwolnijmy... Ale co? Ten g", substr);
        }

        [TestMethod]
        public void byNotExistingChar()
        {
            string substr = text.SubstringLastTo("X");
            Assert.AreEqual("", substr);
        }

        [TestMethod]
        public void byFirstChar()
        {
            string substr = text.SubstringLastTo("Z");
            Assert.AreEqual("Z", substr);
        }
    }
}
